using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace RuntimeCommand { 
[CommandID("addCount", "add a count  param: number")]
public struct AddCount : Command
{
    public void Execute(params object[] param)
    {
        if (param.Length == 0)
        {
            return;
        }
        if (float.TryParse(param[0].ToString(),out float value))
        {
            Example.count += value;
            Example.OnCountChange?.Invoke(Example.count);
        }
    }
}

public class Example : MonoBehaviour
{
    public Text text;

    public static float count = 0;
    public static UnityEvent<float> OnCountChange = new UnityEvent<float>();
    private void Start()
    {
        text.text = count.ToString();
        OnCountChange.AddListener((v) => { 
            text.text = v.ToString();
        });
    }


}
}